package com.mew.auc.rest;


import com.mew.auc.config.MewGameConfig;
import com.zebra.common.ServerBriefInfo;
import lombok.*;

@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ConfigInfoResponse {

    private int versionLobby;  //大厅客户端版本号
    private int versionError;   //错误码版本号
    private String hostUrl;       // 热更地址
    private String wxId;        // 微信信息
    private String wxSecret;
    private int sign;    //表示符号 $ #
    private int    rate;    //1000  100
    private int    digits;  //2  表示保留2位

    private String gwIp; // 网关IP
    private int  gwPort;  // 网关端口


    public ConfigInfoResponse buildData(MewGameConfig config, ServerBriefInfo serverBriefInfo){
        this.versionLobby = config.getVersionLobby();
        this.versionError = config.getVersionError();
        this.hostUrl = config.getHostUrl();
        this.wxId = config.getWxId();
        this.wxSecret = config.getWxSecret();
        this.gwIp = serverBriefInfo.getIp();
        this.gwPort = serverBriefInfo.getPort();
        String rate = config.getLobbyRate(); //@NacosProperty(value = "lobby.rate")
        String[] str = rate.split("-");
        this.sign = Integer.parseInt(str[2]);
        this.rate = Integer.parseInt(str[0]);
        this.digits = Integer.parseInt(str[1]);
        return this;
    }
}
